package wwwContinent;

import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

public class ServletDemo03 extends HttpServlet {

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        ServletContext servletContext = getServletContext();
        //虚拟路径
        System.out.println("虚拟路径：" + servletContext.getContextPath());

        System.out.println("getResource:" + servletContext.getResource("a.txt"));
        System.out.println("getResource:" + servletContext.getResource("WEB-INF/b.txt"));
        System.out.println("getRealPath:" + servletContext.getRealPath("c.txt"));
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doGet(req, resp);
    }
}
